package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.common.core.util.CodeUtils;
import com.engine4cloud.tdf.supervision.dto.create.RcglDailyReportCreateDTO;
import com.engine4cloud.tdf.supervision.dto.result.RcglDailyReportResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.RcglDailyReportUpdateDTO;
import com.engine4cloud.tdf.supervision.entity.RcglDailyReportEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

@Mapper
public interface RcglDailyReportConvert {

    RcglDailyReportConvert INSTANCE = Mappers.getMapper(RcglDailyReportConvert.class);

    RcglDailyReportEntity createTo(RcglDailyReportCreateDTO s);

    RcglDailyReportEntity update(RcglDailyReportUpdateDTO s);

    RcglDailyReportResultDTO convert(RcglDailyReportEntity s);

    default RcglDailyReportEntity create(RcglDailyReportCreateDTO s, Long tenantId) {
        RcglDailyReportEntity entity = createTo(s);
        entity.setTenantId(tenantId);
        entity.setLcbh(CodeUtils.entrustCode());
        return entity;
    }
}
